<template>
	<view class="reply-container">
		<view style="padding: 20rpx;">
			<view class="title"><text style="color: red;">*</text>完成描述</view>
			<textarea class="content" v-model="params['完成描述']" placeholder="请输入任务完成描述..." name="" id="" cols="30" rows="10"></textarea>
		</view>
		<view class="title" style="margin-left: 20rpx;"><text style="color: red;">*</text>处理附件</view>
		<view style="margin-left: 8rpx;">
			<uploader :max="10" @input='onchange'></uploader>
		</view>
		<!-- <button @click="upload">上传</button> -->
		<!-- <view class="title" style="margin-left: 20rpx;">业主签字</view>
		<view class="sign-item" @click="goSignPage">
			<image :src="resultUrl" mode=""></image>
		</view> -->
		<button style="margin-bottom: 60rpx;" class="btn" @click="submit">提交</button>
	</view>
</template>

<script>
	import uploader from '@/components/my-components/image-uploader.vue'
	export default {
		data() {
			return {
				params: {
					任务id: null,
					完成描述: '',
					附件: [],
					附件名称: []
				},
				resultUrl: '../../static/icon/8.png',
				file: {
					fileName: null,
					fileData: null
				}
			}
		},
		components: {
			uploader
		},
		onShow() {
			
		},
		onLoad(options) {
			this.params.任务id = [+options.id]
		},
		methods: {
			onchange(e) {
				this.params.附件 = e
			},
			submit() {
				if(this.params.完成描述.trim() == ''){
					uni.showToast({
						title: '请填写完成描述',
						icon: 'none'
					})
				}else {
					this.completeTask()
				}
			},
			completeTask() {
				// this.params.id = parseInt(this.ticketId)
				// this.params.操作类型 = 'complete'
				for(let i = 1; i <= this.params.附件.length; i++) {
					this.params.附件名称.push(`${i}.png`)
				}
				uni.showLoading({mask: true})
				this.$http.post('taskSystem/task/submit', this.params).then(res => {
					console.log(res)
					if (res.code === 10000) {
						uni.redirectTo({
							url: '/taskSystem/operateSuccess/operateSuccess?path=../taskDetail/taskDetail' + '&id=' + this.params.任务id[0]
						})
						// uni.redirectTo({
						// 	url: '/ticketSystem/acceptSuccess/acceptSuccess?path=/taskSystem/list/list' + '&title=返回任务首页'
						// })
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.reply-container {
		// padding: 20rpx;
		.title {
			margin-bottom: 20rpx;
		}
		.content {
			width: 710rpx;
			padding: 20rpx;
			border: 2rpx solid #ccc;
		}
		.btn {
			width: 568rpx;
			height: 80rpx;
			line-height: 80rpx;
			margin-top: 100rpx;
			background: linear-gradient(to right, #3350D9, #1152FC);
			// background-color: #1152FC;
			color: #fff;
		}
		.sign-item {
			margin-left: 20rpx;
			width: 220rpx;
			height: 220rpx;
			image {
				width: 100%;
				height: 100%;
			}
		}
	}
</style>